#!/bin/sh

# Edit the `.okapi` file in your home directory to contain something like:
#
#	OKAPI_URL=https://east-okapi.folio-dev.indexdata.com
#	OKAPI_TENANT=reshare_east
#	OKAPI_TOKEN=xxxxxxxx
#
# Now you can issue much simpler curl commands by using `okapi-curl`, for example:
#
#	okapi-curl http://localhost:9130/copycat/target-profiles

if [ $# = 0 ]; then
   echo "Usage: $0 <path> [<curl-options>]" >&2
   exit 1;
fi

path="$1"
shift

. ~/.okapi
exec curl \
	-H "X-Okapi-Tenant: $OKAPI_TENANT" \
	-H "X-Okapi-Token: $OKAPI_TOKEN" \
	-H "Content-Type: application/json" \
	-H "Accept: application/json" \
	${@+"$@"} \
	"$OKAPI_URL/$path"
